<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>测试接口页面</title>
	<style type="text/css">
		input{margin-bottom: 10px;}
	</style>
	<script type="text/javascript" src="../js/mui.min.js"></script>
	<script type="text/javascript" src="../js/jquery-3.2.1.min.js"></script>

</head>
<body>
	<input type="button" name="" value="商品存信息-查询" id="p_select">
	<div class="p_select"></div>
	
	<input type="button" name="" value="添加到购物车" id="add_cart">
	<div class="add_cart"></div>
	
	<input type="button" name="" value="查询购物车" id="select_cart">
	<div class="select_cart"></div>
	
	<input type="button" name="" value="修改购物车" id="deatil_cart">
	<div class="deatil_cart"></div>
	<script src="../js/Fn.js"></script>
	<script type="text/javascript">
//		URL_all
//f0651922601a4546b6f6d0403a5c33d7
		$("#p_select").on("tap",function(){
			mui.ajax(URL_all+'api/bizrelatives/selectcmmybyparents?page=2&pagesize=3',{
				//查询产品分类
				data:{'tosort':'asc', 'sorting':'present_price','catalogId':'1'},
				dataType:'json',//服务器返回json格式数据
				type:'post',//HTTP请求类型
				timeout:10000,//超时时间设置为10秒；
				headers:{'Content-Type':'application/json'},	              
				success:function(data){
					//服务器返回响应，根据响应结果，分析是否登录成功；
					console.log(data.pageInfo.list);
					console.log(JSON.stringify(data.pageInfo.list[0]));//commodityNumber:1514361086167
					
					$(".p_select").html("查询到商品:"+data.pageInfo.list[0].title+",<br/>商品条码为:<span id='Pnumber'>"+data.pageInfo.list[0].commodityNumber+"</span>");
				},
				error:function(xhr,type,errorThrown){
					//异常处理；
					console.log(type);
				}
			});
		})
		
		$("#add_cart").on("tap",function(){
			mui.ajax(URL_all+'client/detailed/insertdetailed',{
				//查询产品分类
				data:{'commodityNumber':$("#Pnumber").html(),'needNumber':'999','add_price':'0.1','add_time':'123'},
				dataType:'json',//服务器返回json格式数据
				type:'post',//HTTP请求类型
				timeout:10000,//超时时间设置为10秒；
				headers:{'Content-Type':'application/json',"userToken":localStorage.userToken},	              
				success:function(data){
					//服务器返回响应，根据响应结果，分析是否登录成功；
					console.log(data);
//					console.log(JSON.stringify(data.pageInfo.list[0]));//commodityNumber:1514361086167
					$(".add_cart").html("状态是:"+data.htmlState.status+"<br/>添加的商品条码为:"+data.dataResultObj.commodityNumber)
//					$(".p_select").html(JSON.stringify(data.pageInfo.list[0]))
				},
				error:function(xhr,type,errorThrown){
					//异常处理；
					console.log(type);
				}
			});
		});
		
		$("#select_cart").on("tap",function(){
			mui.ajax(URL_all+'client/detailed/selectbyuserId?adcode=10000&page=1&pagesize=12',{
				//查询产品分类
				data:'',
				dataType:'json',//服务器返回json格式数据
				type:'get',//HTTP请求类型
				timeout:10000,//超时时间设置为10秒；
				headers:{'Content-Type':'application/json',"userToken":localStorage.userToken},	              
				success:function(data){
					//服务器返回响应，根据响应结果，分析是否登录成功；
					console.log(data.pageInfo.list);
//					console.log(JSON.stringify(data.pageInfo.list));//commodityNumber:1514361086167
					$(".select_cart").html("状态是:"+data.htmlState.status)
//					$(".p_select").html(JSON.stringify(data.pageInfo.list[0]))
				},
				error:function(xhr,type,errorThrown){
					//异常处理；
					console.log(type);
				}
			});
		})
		
		$("#deatil_cart").on("tap",function(){
			mui.ajax(URL_all+'client/detailed/updatebyuserid',{
				//查询产品分类
				data:{'commodityNumber':$("#Pnumber").html(),'needNumber':'0250'},
				dataType:'json',//服务器返回json格式数据
				type:'post',//HTTP请求类型
				timeout:10000,//超时时间设置为10秒；
				headers:{'Content-Type':'application/json',"userToken":localStorage.userToken},	              
				success:function(data){
					//服务器返回响应，根据响应结果，分析是否登录成功；
					console.log(data);
				},
				error:function(xhr,type,errorThrown){
					//异常处理；
					console.log(type);
				}
			});
		});
		
	</script>
</body>
</html>